﻿#pragma execution_character_set("utf-8")

#include "forms-widget.h"
#include "ui_formswidget.h"
#include "toast.h"
#include "notifymanager.h"
using namespace Forms;
FormsWidget::FormsWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::FormsWidget)
{
    ui->setupUi(this);
    man = new NotifyManager(this);
}

FormsWidget::~FormsWidget()
{
    delete ui;
}


void FormsWidget::on_btn_long_notify_clicked()
{
    auto text = ui->ledit_long_notify->text().trimmed();
    if(text.isEmpty()) {
        emptyToast();
    } else {
        man->notify(this, "长通知", text, 1000*10);
    }

}

void FormsWidget::on_bnt_short_notify_clicked()
{
    auto text = ui->ledit_short_notify->text().trimmed();
    if(text.isEmpty()) {
        emptyToast();
    } else {
        man->notify(this, "短通知", text, 1000);
    }
}

void FormsWidget::emptyToast()
{
    Forms::Toast::showToast(this, "请输入字符");
}

void FormsWidget::on_btn_toast_clicked()
{
    auto text = ui->ledit_toast->text().trimmed();
    if(text.isEmpty()) {
        emptyToast();
    } else {
        Toast::showToast(this, text);
    }
}
